<template>
    <div class="app-container">
        <tablebase
            ref="tablebase"
            :apis="apis"
            :sumShow="sumShow"
            :indexShow="indexShow"
            :searchItems="searchItems"
            :headItems="headItems"
            :formItems="formItems"
            :buttonItems="buttonItems"
            :actItems="actItems"
            @actButEvent="actButEvent"
        />
    </div>
</template>

<script>
    export default {
        name: "demo",
        data() {
            return {
                // 显示合计
                sumShow: false,
                // 显示顺序
                indexShow: true,
                // 搜索栏
                searchItems: [
                    {
                        key: "name",
                        placeholder: "请输入会员昵称"
                    },
                    {
                        key: "phone",
                        placeholder: "请输入手机号码"
                    },
                    {
                        type: "datetimerange",
                        key: "datetimerange"
                    },
                    {
                        type: "select",
                        key: "status",
                        placeholder: "请输入店员状态",
                        options: [
                            { key: "在职", value: "INCUMBENCY" },
                            { key: "离职", value: "DIMISSION" }
                        ]
                    }
                ],
                // 按钮
                buttonItems: [
                    {
                        label: "添 加",
                        key: "addEdit"
                    },
                    {
                        label: "批量删除",
                        key: "delete"
                    },
                    {
                        label: "导 出",
                        key: "export"
                    }
                ],
                // 表头
                headItems: [
                    {
                        key: "companyName",
                        label: "企业名",
                        type: "textClick"
                    },
                    {
                        key: "familyName",
                        label: "公会名称"
                    },
                    {
                        key: "familyImg",
                        label: "公会图片",
                        type: "image",
                        formatter: e => {
                            return e.familyImg;
                        }
                    },
                    {
                        key: "status",
                        label: "状态",
                        type: "dict",
                        dictType: "examineStatus",
                        tagType: "examineStatusTag"
                    },
                    {
                        key: "verifyTime",
                        label: "审核时间",
                        type: "time",
                        option: "YYYY-MM-DD HH:mm:ss"
                    },
                    {
                        key: "查看业绩",
                        label: "主播",
                        type: "butClick"
                    },
                    {
                        key: "status",
                        label: "礼物状态",
                        type: "switch",
                        dictType: "ableStatus"
                    }
                ],
                // 表单
                formItems: [
                    {
                        label: "输入框",
                        key: "name",
                        placeholder: "请输入会员昵称",
                        disabled: true,
                        rule: ["NotBlank"]
                    },
                    {
                        label: "富文本",
                        key: "money",
                        placeholder: "请输入手机号码",
                        type: "textarea",
                        rule: ["NotBlank", "MAX|20", "MIN|5", "VAL|0~256"]
                    },
                    {
                        label: "单选",
                        key: "tag",
                        type: "radio",
                        options: [
                            { key: "在职", value: "INCUMBENCY" },
                            { key: "离职", value: "DIMISSION" }
                        ],
                        rule: ["NotBlank"]
                    },
                    {
                        label: "时间",
                        type: "datetime",
                        key: "hiredate",
                        rule: ["NotBlank"]
                    },
                    {
                        label: "下拉框",
                        type: "select",
                        key: "status",
                        multiple: false,
                        options: [{ key: "是", value: 1 }, { key: "否", value: 0 }],
                        optionsUrl: this.$apis.system.roleGetList,
                        rule: ["NotBlank"]
                    },
                    {
                        label: "视频上传",
                        type: "mvideo",
                        key: "mvideo",
                        rule: ["NotBlank"]
                    },
                    {
                        label: "图片上传",
                        type: "image",
                        key: "image",
                        rule: ["NotBlank"],
                        width: 100,
                        height: 100
                    },
                    {
                        label: "权限设置",
                        type: "tree",
                        key: "tree",
                        rule: ["NotBlank"],
                        tip:
                            "请以 'ROLE_XXX_XXX' 为格式命名角色名称 (例如: ROLE_MANAGE_GUILD)"
                    }
                ],
                // 操作
                actItems: [
                    {
                        label: "编辑",
                        key: "addEdit",
                        type: "success",
                        show: e => {
                            return e.tag == "DIMISSION" ? false : true;
                        }
                    },
                    {
                        label: "离职",
                        key: "quit",
                        type: "info",
                        show: e => {
                            return e.tag == "DIMISSION" ? false : true;
                        }
                    },
                    {
                        label: "调动",
                        key: "transfer",
                        type: "warning",
                        show: e => {
                            return e.tag == "DIMISSION" ? false : true;
                        }
                    },
                    {
                        label: "删除",
                        key: "delete",
                        type: "danger"
                    }
                ],

                apis: {
                    list: this.$api.V2X_ABNORMAL_GET,
                    // or
                    /*list: {
                        url: this.$apis.virtualGoods.giftGetList,
                        params: {
                            params: params
                        }
                    },*/

                    get: this.$api.V2X_ABNORMAL_GET,
                    add: this.$api.V2X_ABNORMAL_GET,
                    update: this.$api.V2X_ABNORMAL_GET,
                    delete: this.$api.V2X_ABNORMAL_GET,
                    detail: this.$api.V2X_ABNORMAL_GET,
                    export: "export",
                    noAllDelete: true
                }
            };
        },
        methods: {
            actButEvent(e) {
                this[e.eventName](e.val);
            },
            addEdit(e) {
                this.$refs.tablebase.addEditEvent(e);
            },
            delete(e) {
                this.$refs.tablebase.deleteEvent(e);
            }
        }
    };
</script>

<style scoped>
</style>
